import request from '@/utils/request'

/**
 * 我的通知初始化
 * @param {Number} id 代理商id
 */
export function myPublishInit(id) {
  return request({
    url: '/myPublish',
    method: 'GET',
    params: { id }
  })
}

export function myPublishPage(id, page, date) {
  return request({
    url: '/myPublish',
    method: 'GET',
    params: { id, page, keyword: date.keyword, start: date.start, end: date.end }
  })
}

export function myPublishSearch(id, date) {
  return request({
    url: '/myPublish',
    method: 'GET',
    params: { id, keyword: date.keyword, start: date.start, end: date.end }
  })
}

export function addSubmit(date, author) {
  const data = { content: date.conteny, title: date.title, author, posted: date.posted }
  return request({
    url: '/add',
    method: 'POST',
    data
  })
}

export function again(date, author, id) {
  const data = { content: date.conteny, title: date.title, author, posted: date.posted, id }
  return request({
    url: '/again',
    method: 'POST',
    data
  })
}

export function issueInit(id) {
  return request({
    url: '/again',
    method: 'GET',
    params: { id }
  })
}

export function del(id) {
  const data = { id }
  return request({
    url: '/del',
    method: 'POST',
    data
  })
}
/**
 * 查看通知
 * @param {Number} id 通知id
 */
export function listInit(id) {
  return request({
    url: '/see',
    method: 'GET',
    params: { id }
  })
}

/**
 * 收到通知
 * @param {Number} id 代理商id
 */
export function receivePublishInit(id) {
  return request({
    url: '/receivePublish',
    method: 'GET',
    params: { id }
  })
}

export function receivePublishPage(id, page, date) {
  return request({
    url: '/receivePublish',
    method: 'GET',
    params: { id, page, keyword: date.keyword, start: date.start, end: date.end }
  })
}

export function receivePublishSearch(id, date) {
  return request({
    url: '/receivePublish',
    method: 'GET',
    params: { id, keyword: date.keyword, start: date.start, end: date.end }
  })
}

export function check(id, mesid) {
  return request({
    url: '/browse',
    method: 'GET',
    params: { id: mesid, user_id: id }
  })
}
